<%@page import="com.alibaba.fastjson.JSONArray"%>
<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
	List<Map<String,Object>> listUserOwnStore = (List<Map<String,Object>>)session.getAttribute("listUserOwnStore");
	String storeListstr = JSONArray.toJSONString(listUserOwnStore);
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>会员报告</title>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<style type="text/css">
body{font-size: 14px;}.dataTables_info {font-size: 12px}.dataTables_paginate {font-size: 12px;}
.yellow_circle{
    width: 120px;
    height: 120px;
    background: #fee087;
    border-radius: 50%;
    padding-top: 30px;
    margin: 4px;
}
.yellow_circle p{
    color: #333;
    text-align: center;
}
.yellow_circle p.people{
    color: #8f721c;
    font-size: 20px;
}
.yellow_circle_border{            
    width:130px;
    height:130px;
    border:1px solid #fee087;
    border-radius: 50%;
    display: inline-block;
}
.k_blue {
	border-color: #c9cff5;
}
.k_blue .yellow_circle {
    background: #c9cff5;
}
</style>
</head>
<body class="gray-bg">
<div class="container-fluid">
	<div style="height: 20px;"></div>
	<div class="row" style="line-height: 34px;">
		<div class="col-sm-1">门店选择</div>
		<div class="col-sm-2">
			<select id="store" class="form-control">
			</select>
		</div>
		<div class="col-sm-3">
			<div class="btn-group">
			    <button class="btn btn-primary" type="button">昨天</button>
			    <button class="btn btn-white" type="button">近1周</button>
			    <button class="btn btn-white" type="button">近1月</button>
			    <button class="btn btn-white" type="button">自定义</button>
			</div>
		</div>
		<div class="col-sm-3">
	        <div class="input-daterange input-group">
	            <input type="text" class="input-sm form-control" name="datetimepicker_start" readonly disabled style="background-color: white;height:34px;">
	            <span class="input-group-addon" style="background-color: #eeeeee;">到</span>
	            <input type="text" class="input-sm form-control" name="datetimepicker_end" readonly disabled style="background-color: white;height:34px;">
	        </div>
		</div>
		<div class="col-sm-3 text-right">
			<button id="search" class="btn btn-primary" type="button">筛选</button>
			<shiro:hasPermission name="member_report:export_pdf">
			<button id="downPDF" class="btn btn-primary" type="button">导出PDF</button>
			</shiro:hasPermission>
		</div>
	</div>
	<div style="height: 40px;"></div>
	<div class="row">
		<div class="col-sm-1"></div>
		<div class="col-sm-2 text-center">
			<div class="yellow_circle_border"><div class="yellow_circle"><p>新增会员</p><p class="people"><span>0</span><br/>人</p></div></div>
		</div>
		<div class="col-sm-2 text-center">
			<div class="yellow_circle_border k_blue"><div class="yellow_circle"><p>消费会员</p><p class="people"><span>0</span><br/>人</p></div></div>
		</div>
		<div class="col-sm-2 text-center">
			<div class="yellow_circle_border"><div class="yellow_circle"><p>参与活动会员</p><p class="people"><span>0</span><br/>人</p></div></div>
		</div>
		<div class="col-sm-2 text-center">
			<div class="yellow_circle_border k_blue"><div class="yellow_circle"><p>储值会员</p><p class="people"><span>0</span><br/>人</p></div></div>
		</div>
		<div class="col-sm-2 text-center">
			<div class="yellow_circle_border"><div class="yellow_circle"><p>复购会员</p><p class="people"><span>0</span><br/>人</p></div></div>
		</div>
	</div>
	<div id="memberBarAll_memberLineAll" style="display: none;">
		<div style="height: 40px;"></div>
		<div class="row">
			<div class="col-sm-12">
				<div class="btn-group">
				    <button class="btn btn-primary" type="button">新增会员</button>
				    <button class="btn btn-white" type="button">消费会员</button>
				    <button class="btn btn-white" type="button">参与活动会员</button>
				    <button class="btn btn-white" type="button">储值会员</button>
				    <button class="btn btn-white" type="button">复购会员</button>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-12">
				<div id="memberBarAll" style="height: 400px;"></div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-12">
				<div id="memberLineAll" style="height: 400px;"></div>
			</div>
		</div>
	</div>
	<div style="height: 40px;"></div>
	<div class="row">
		<div class="col-sm-12">
			<div id="memberLine" style="height: 400px;"></div>
		</div>
	</div>
	<div style="height: 40px;"></div>
	<div class="row">
		<div class="col-sm-11"></div>
		<div class="col-sm-1">
			<a id="export" href="javascript:void(0)" target="_blank">
			<shiro:hasPermission name="member_report:export_data">
			<button class="btn btn-primary" type="button">导出数据</button>
			</shiro:hasPermission>
			</a>
		</div>
	</div>
	<div class="row">
		<div class="col-sm-12">
			<table id="myTable" class="display">
				<thead>
					<tr>
						<th>日期</th>
						<th>门店</th>
		                <th>新增会员</th>
		                <th>消费会员</th>
		                <th>参与活动会员</th>
		                <th>储值会员</th>
		                <th>复购会员</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/3.7.2/echarts.common.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-beta4/html2canvas.min.js"></script>
<script type="text/javascript">
var path = "<%=path%>";
var myDataTable = null;
var startTime = "";
var endTime = "";
<%-- var storeArr = <%=storeListstr%>; --%>
var storeArr = [{"storeId":2,"storeName":"22"},{"storeId":1,"storeName":"11"}];
var reportAllIndex = 0;
var COLORS = ['#ffce67','#d59dff','#ffa954','#ff6668','#1db75f','#2192ca','#fbb16c','#6e53d6','#6badff','#8f72fe','#0072ff'];


//ajax全局同步、此处功能不需要异步
$.ajaxSetup({  
    async : false  
});
$(function(){
	$("input[name='datetimepicker_start']").datetimepicker({language:"zh-CN",format: 'yyyy-mm-dd',autoclose: true,minView:2})
	.on("click",function(){
        $("input[name='datetimepicker_start']").datetimepicker("setEndDate",$("input[name='datetimepicker_end']").val())
    }).on('changeDate', function(ev){
//     	$(".btn-group:eq(0)>button:eq(0)").removeClass("btn-white").addClass("btn-primary").siblings().removeClass("btn-primary").addClass("btn-white");
    	startTime = $("input[name='datetimepicker_start']").val();
    });
	$("input[name='datetimepicker_end']").datetimepicker({language:"zh-CN",format: 'yyyy-mm-dd',autoclose: true,minView:2}).on("click",function(){
        $("input[name='datetimepicker_end']").datetimepicker("setStartDate",$("input[name='datetimepicker_start']").val())
    }).on('changeDate', function(ev){
//     	$(".btn-group:eq(0)>button:eq(0)").removeClass("btn-white").addClass("btn-primary").siblings().removeClass("btn-primary").addClass("btn-white");
    	endTime = $("input[name='datetimepicker_end']").val();
    });
	
	$(".btn-group:eq(0)>button").click(function(){
		var index = $(this).index();
		var now = new Date();
		$(this).removeClass("btn-white").addClass("btn-primary").siblings().removeClass("btn-primary").addClass("btn-white");
		if(index == 0){
			now.setDate(now.getDate() - 1);
			startTime = now.Format("yyyy-MM-dd");
			endTime = startTime;
		}else if(index == 1){
			endTime = now.Format("yyyy-MM-dd");
			now.setDate(now.getDate() - 7);
			startTime = now.Format("yyyy-MM-dd");
		}else if(index == 2){
			endTime = now.Format("yyyy-MM-dd");
			now.setDate(now.getDate() - 30);
			startTime = now.Format("yyyy-MM-dd");
		}else if(index == 3){
			$("input[name='datetimepicker_start']").removeAttr("disabled");
			$("input[name='datetimepicker_end']").removeAttr("disabled");
			return ;
		}
		$("input[name='datetimepicker_start']").attr("disabled",true);
		$("input[name='datetimepicker_end']").attr("disabled",true);
		$("input[name='datetimepicker_start']").val(startTime);
		$("input[name='datetimepicker_end']").val(endTime);
		
		init();
	});
	
	$(".btn-group:eq(1)>button").click(function(){
		var index = $(this).index();
		$(this).removeClass("btn-white").addClass("btn-primary").siblings().removeClass("btn-primary").addClass("btn-white");
		reportAllIndex = index;
		
		init();
	});
	
	$("#store").change(function(){
		if($(this).val().split(",").length>1){
			$("#memberBarAll_memberLineAll").show();
		}else{
			$("#memberBarAll_memberLineAll").hide();
		}
		init();
	});
	
	$("#search").click(function(){
		init();
	});
	
	$("#downPDF").click(function(){
		html2canvas(document.body, {
            onrendered:function(canvas) {
            	var contentWidth = canvas.width;
                var contentHeight = canvas.height;

                //一页pdf显示html页面生成的canvas高度;
                var pageHeight = contentWidth / 592.28 * 841.89;
                //未生成pdf的html页面高度
                var leftHeight = contentHeight;
                //页面偏移
                var position = 0;
                //a4纸的尺寸[595.28,841.89]，html页面生成的canvas在pdf中图片的宽高
                var imgWidth = 595.28;
                var imgHeight = 592.28/contentWidth * contentHeight;

                var pageData = canvas.toDataURL('image/jpeg', 1.0);

                var pdf = new jsPDF('', 'pt', 'a4');

                //有两个高度需要区分，一个是html页面的实际高度，和生成pdf的页面高度(841.89)
                //当内容未超过pdf一页显示的范围，无需分页
                if (leftHeight < pageHeight) {
          	  		pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight );
                } else {
          	      while(leftHeight > 0) {
          	          pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
          	          leftHeight -= pageHeight;
          	          position -= 841.89;
          	          //避免添加空白页
          	          if(leftHeight > 0) {
          		        pdf.addPage();
          	          }
          	      }
                }

                pdf.save('content.pdf');
            },background: '#FFF'
        })
	});
	

	
	$("#export").click(function(){
		var storeId = "";
		var storeIds = "";
		if($("#store").val().split(",").length>1){
			storeIds = $("#store").val();
	    }else{
	    	storeId = $("#store").val();
	    }
		var href = path+"/memberReport/exportMemberReport";
		href += "?startTime="+startTime+"&endTime="+endTime+"&storeId="+storeId+"&storeIds="+storeIds;
		$(this).attr("href",href);
	});
	
	init();
});

function init(){
	if($("#store>option").size()==0){
		var option = "";
		var storeIds = "";
		$.post(
				path + "/memberReport/ajaxStoreList",
				{},
				function(e){
					if(e.status == "1"){
						for(var i = 0 ; i < e.data.length ; i ++){
							var d = e.data[i];
							var selected = "";
							option += "<option value='"+d.id+"' "+selected+">"+d.name+"</option>";
							storeIds += ","+d.id;
						}
					}
					if(e.data.length >1){
						storeIds = storeIds.substr(1);
						option = "<option value='"+storeIds+",0'>全部</option>" + option;
						$("#memberBarAll_memberLineAll").show();
					}
					$("#store").html(option); 
				},
				"json"
			);
		
	}
	if(startTime=="" && endTime==""){
		var now = new Date();
		now.setDate(now.getDate()-1);
		startTime = now.Format("yyyy-MM-dd");
		endTime = startTime;
		$("input[name='datetimepicker_start']").val(startTime);
		$("input[name='datetimepicker_end']").val(endTime);
	}
	func_sumAll();
	func_memberLine();
	if(myDataTable == null){
		myDataTable = dataTable();
	}else{
		func_dataTableReload(true);
	}
	if(!$("#memberBarAll_memberLineAll").is(":hidden")){
		func_memberBarAll();
	}
}

function func_sumAll(){
	//var obj = null
	//var obj = {startTime:startTime,endTime:endTime};
	/* if($("#store").val() != null){
		if($("#store").val().split(",").length>1){
			obj.storeIds = $("#store").val(); 
	    }else{
	    	obj.storeId = $("#store").val();
	    }
	} */
	$.post(
			path + "/memberReport/ajaxSumAll",
			{
				"startTime":startTime,
				"endTime":endTime,
				"storeIds":$("#store").val()
			},
			function(data){
			
				if(data.status == "1"){
					$(".people:eq(0)>span").text(data.data.createCustomerNumber);
					$(".people:eq(1)>span").text(data.data.consumeCustomerNumber);
					$(".people:eq(2)>span").text(data.data.joinCustomerNumber);
					$(".people:eq(3)>span").text(data.data.balanceCustomerNumber);
					$(".people:eq(4)>span").text(data.data.rePurchaseCustomerNumber);
				}
			},
			"json"
		);
}

function func_memberLine(){
	//var obj = {startTime:startTime,endTime:endTime};
	/* if($("#store").val() != null){
		if($("#store").val().split(",").length>1){
			obj.storeIds = $("#store").val();
	    }else{
	    	obj.storeId = $("#store").val();
	    }
	} */
	$.post(
			path + "/memberReport/ajaxMemberLine",
			{
				"startTime":startTime,
				"endTime":endTime,
				"storeIds":$("#store").val()
			},
			function(data){
			if(data.status == "1"){
			var legend_data = ['新增会员','消费会员','参与活动','储值会员','复购会员'];
		 	var x_data = [];
		 	var y_data = [];
		 	var y1 = [];
		 	var y2 = [];
		 	var y3 = [];
		 	var y4 = [];
		 	var y5 = [];
		 	$.each(data.data,function(i,d){
		 		var x = d.crmDate.split("-");
		 		x = x[0]+x[1]+x[2];
		 		x_data.push(x);
		 		y1.push(d.createCustomerNumber);
		 		y2.push(d.consumeCustomerNumber);
		 		y3.push(d.joinCustomerNumber);
		 		y4.push(d.balanceCustomerNumber);
		 		y5.push(d.rePurchaseCustomerNumber);
		 	});
		 	y_data.push({name:'新增会员',type:'line',smooth:true,data:y1});
		 	y_data.push({name:'消费会员',type:'line',smooth:true,data:y2});
		 	y_data.push({name:'参与活动',type:'line',smooth:true,data:y3});
		 	y_data.push({name:'储值会员',type:'line',smooth:true,data:y4});
		 	y_data.push({name:'复购会员',type:'line',smooth:true,data:y5});
		 	func_line("memberLine","会员走势图",legend_data,x_data,y_data);
		}
	},"json");
}

function func_memberBarAll(){
	//var obj = {startTime:startTime,endTime:endTime,index:reportAllIndex,storeIds:$("#store").val()};
	$.post(
			path + "/memberReport/ajaxMemberBarAll",
			{
				"startTime":startTime,
				"endTime":endTime,
				"index":reportAllIndex,
				"storeIds":$("#store").val()
			},
			function(data){
		if(data.status == "1"){
			var legend_data = [];
			if(reportAllIndex == 0){
				legend_data = ['新增会员'];
			}else if(reportAllIndex == 1){
				legend_data = ['消费会员'];
			}else if(reportAllIndex == 2){
				legend_data = ['参与活动'];
			}else if(reportAllIndex == 3){
				legend_data = ['储值会员'];
			}else if(reportAllIndex == 4){
				legend_data = ['复购会员'];
			}
		 	var x_data = [];
		 	var y_data = [];
		 	var y1 = [];
		 	var tempStoreIds = "";
		 	$.each(data.data,function(i,d){
		 		x_data.push(d.storeName);
		 		y1.push(d.createCustomerNumber);
		 		tempStoreIds += ","+d.storeId
		 	});
		 	if(tempStoreIds.length > 0){
		 		tempStoreIds = tempStoreIds.substr(1);
			 	func_memberLineAll(tempStoreIds);
		 	}
		 	y_data.push({name:legend_data[0],type:'bar',barGap:0,data:y1,itemStyle:{
				normal: {
					color: function(params) {
						return COLORS[reportAllIndex]
					}
				}
			}});
		 	func_bar("memberBarAll","店铺排行",legend_data,x_data,y_data);
		}
	},"json");
}

function func_memberLineAll(tempStoreIds){
	var obj = {startTime:startTime,endTime:endTime,storeIds:tempStoreIds};
	$.post(path + "/memberReport/ajaxMemberLineAll",obj,function(data){
		if(data.status == "1"){
			var legend_data = [];
		 	var x_data = [];
		 	var y_data = [];
		 	var title = "";
		 	if(reportAllIndex == 0){
	 			title = "店铺新增会员走势对比图";
			}else if(reportAllIndex == 1){
				title = "店铺消费会员走势对比图";
			}else if(reportAllIndex == 2){
				title = "店铺参与活动员走势对比图";
			}else if(reportAllIndex == 3){
				title = "店铺储值会员走势对比图";
			}else if(reportAllIndex == 4){
				title = "店铺复购会员走势对比图";
			}
		 	
		 	$.each(data.data,function(i,d){
		 		if($.inArray(d.storeName,legend_data) < 0){
		 			legend_data.push(d.storeName);
		 		}
		 		if($.inArray(d.crmDate,x_data) < 0){
			 		x_data.push(d.crmDate);
		 		}
		 	});
		 	$.each(legend_data,function(i,d){
		 		y_data.push({name:d,type:'line',smooth:true,data:[]});
		 	});
		 	var temp_y = [];
		 	$.each(data.data,function(i,d){
		 		var value = 0;
		 		if(reportAllIndex == 0){
		 			value = d.createCustomerNumber;
				}else if(reportAllIndex == 1){
					value = d.consumeCustomerNumber;
				}else if(reportAllIndex == 2){
					value = d.joinCustomerNumber;
				}else if(reportAllIndex == 3){
					value = d.balanceCustomerNumber;
				}else if(reportAllIndex == 4){
					value = d.rePurchaseCustomerNumber;
				}
		 		if(temp_y.length>0 && temp_y[temp_y.length-1].crmDate!=d.crmDate){
					$.each(legend_data,function(i,d1){
						var value = 0;
						$.each(temp_y,function(i,d2){
							if(d1 == d2.name){
								value = d2.value;
								return false;
							}
			 			});
						y_data[i].data.push(value);
		 			});
					temp_y = [];
		 		}
		 		temp_y.push({crmDate:d.crmDate,name:d.storeName,value:value});
		 	});
		 	if(temp_y.length>0){
				$.each(legend_data,function(i,d1){
					var value = 0;
					$.each(temp_y,function(i,d2){
						if(d1 == d2.name){
							value = d2.value;
							return false;
						}
		 			});
					y_data[i].data.push(value);
	 			});
	 		}
		 	func_line("memberLineAll",title,legend_data,x_data,y_data);
		}
	},"json");
}

function func_line(id,title,legend_data,x_data,y_data){
	
    var myChart = echarts.init(document.getElementById(id));

    var option = {
   		title: {
   	        text: title,
   	        x: 'left'
   	    },
   		dataZoom: [
   	        {
   	            show: true,
   	         	start: 40,
   	            end: 60
   	        }
   	    ],
		tooltip : {
   	        trigger: 'axis',
   	        axisPointer: {
   	            type: 'cross',
   	            label: {
   	                backgroundColor: '#6a7985'
   	            }
   	        }
   	    },
        legend: {
        	top:26,
            data:legend_data
        },
        yAxis: {
        	type : 'value'
        },
        xAxis: {
        	data: x_data,
        	boundaryGap : false
        },
        series: y_data
    };
    
	myChart.setOption(option);
	myChart.resize();
}

function func_bar(id,title,legend_data,x_data,y_data){
	 /* var temp = echarts.getInstanceByDom(document.getElementById('id'));
	if(temp != null){
		temp.dispose();
	} */
	var myChart = echarts.init(document.getElementById(id));

    var option = {
  		title: {
			text: title,
			x: 'left'
		},
   		tooltip: {
   	        trigger: 'axis',
   	        axisPointer: {
   	            /* type: 'shadow' */
   	             axisPointer: {
   	   	            type: 'cross',
   	   	            label: {
   	   	                backgroundColor: '#6a7985'
   	   	            }
   	   	        }
   	        }
   	    },
        legend: {
            data:legend_data
        },
        xAxis: {
//         	type: 'value'
        },
        yAxis: {
        	data: x_data,
//         	axisLine: {show: false},
//         	axisTick:{show:false},
        	inverse:true
        },
        series: y_data
    };
    
	myChart.setOption(option);
	myChart.resize();
}

function func_dataTableReload(resetPaging) {
	if(resetPaging != undefined){
	    myDataTable.ajax.reload(null,resetPaging);
	}else{
		myDataTable.ajax.reload();
	}
}


function func_AjaxUrl() {
    return path + "/memberReport/ajaxGetPages";
}

function func_columns() {
    var jsonArr = [
    	{"data": "crmDate"},
    	{"data": "storeName"},
        {"data": "createCustomerNumber"},
        {"data": "consumeCustomerNumber"},
        {"data": "joinCustomerNumber"},
        {"data": "balanceCustomerNumber"},
        {"data": "rePurchaseCustomerNumber"}
    ];
    return jsonArr;
}

function func_ajaxData() {
    var jsonObject = new Object();
    jsonObject.startTime = startTime;
    jsonObject.endTime = endTime;
    if($("#store").val() != null){
	    if($("#store").val().split(",").length>1){
	    	jsonObject.storeIds = $("#store").val(); 
	    }else{
	    	jsonObject.storeId = $("#store").val();
	    }
    }
    return jsonObject;
}

function dataTable() {
    return $('#myTable').DataTable({
        processing: true,
        ordering: false,
        searching: false,
        info: true,
        autoWidth: true,
        lengthChange: false,
        language: {
            emptyTable: '没有数据表',
            info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
            infoEmpty: '没有数据',
            lengthMenu: '每页显示 _MENU_ 条记录',
            loadingRecords: '正在加载数据....',
            processing: '正在处理数据....',
            zeroRecords: '没有找到匹配的记录',
            paginate: {
                first: '首页',
                previous: '前页',
                next: '后页',
                last: '尾页'
            }
        },
        order: [[1, 'desc']],
        pageLength: 10,
        pagingType: 'full_numbers',
        columnDefs: [{
            render: function (data, type, full) {
                var result = "";
//                 if(data != null){
                	result = data;
//                 }
                return result;
            },
            targets: 0
		}],
        columns: func_columns(),
        serverSide: true,
        ajax: {
            contentType: 'application/json;charset=utf-8',
            type: 'POST',
            url: func_AjaxUrl(),
            data: function (d) {
                d.extra_search = func_ajaxData();
                return JSON.stringify(d);
            }
        }
	});
}
Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
</script>
</html>